﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LDTB.Service;

namespace LDTB
{
    public partial class FormMain : Form
    {
        public LoginFrm lf;
        LDTBDataDataContext ds = DataService.DB;

        public FormMain()
        {
            InitializeComponent();
        }
        public FormMain(LoginFrm lf_) {

            lf = lf_;
            InitializeComponent();

            innitializePermission();
        
        }

        private void innitializePermission()
        {
            
            this.huyệnToolStripMenuItem.Enabled = lf.user.IsAdmin.Value;
            this.xãToolStripMenuItem.Enabled = lf.user.IsAdmin.Value;
            this.nhómĐốiTượngToolStripMenuItem.Enabled = lf.user.IsAdmin.Value;
            this.đôToolStripMenuItem.Enabled = lf.user.IsAdmin.Value;
            this.tàiKhoảnToolStripMenuItem.Enabled = lf.user.IsAdmin.Value;

        }

        private void ShowNewForm(object sender, EventArgs e)
        {
           
            FormServeyAdd fs = new FormServeyAdd(lf.user.ID);
            fs.MdiParent = this;
            fs.Show();

        }

        private void OpenFile(object sender, EventArgs e)
        {

            FormServey fs = new FormServey(lf.user.ID);
            fs.MdiParent = this;
            fs.Show();

        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
          
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConfigForm cf = new ConfigForm();
           
            cf.ShowDialog();


        }

        private void quậnHuyệnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WardManager wm = new WardManager();
            wm.MdiParent = this;
            wm.Show();
            
        }

        private void xaxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VillageManger vm = new VillageManger();
            vm.MdiParent = this;
            vm.Show();
          
        }

        private void loạiĐốiTượngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CatObject co = new CatObject();
            co.MdiParent = this;
            co.Show();
        }

        private void lựaChọnChoĐốiTượngToolStripMenuItem_Click(object sender, EventArgs e)
        {

            CatOptFrm co = new CatOptFrm();
            co.MdiParent = this;
            co.Show();

        }

        private void tàiKhoảnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserFrm uf = new UserFrm();
            uf.MdiParent = this;
            uf.Show();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {

        }

        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            lf.Close();
        }

        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            ReportCenter rc = new ReportCenter();
            rc.MdiParent = this;
            rc.Show();
            
        }

        private void printToolStripButton_Click(object sender, EventArgs e)
        {
            ExportReport er = new ExportReport();
            er.Show();
        }

      
        private void danhSáchToànBộToolStripMenuItem_Click(object sender, EventArgs e)
        {


            FormServey fs = new FormServey(lf.user.ID);
            fs.MdiParent = this;
            fs.Show();
        }

        private void thoátToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
           Environment.Exit(0);
        }
    }
}
